/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




function initPendientesGrid(){
    $("#generalistas_grid").jqGrid({
        url:'generalistas.do',
        datatype: "json",
        width:900,
 colNames:['Folio','Gpid','Nombre','Division','SubDivision','Vicepresidencia',
        'Correo','Telefono','Extension','Gpid Jefe','Nombre Jefe','Correo Jefe',' '],
        colModel:[
        {
            name:'folio',
            index:'folio',
            sortable: true, 
             editable: true,       
            editoptions:{readonly: true},        
            width:55
        },

        {
            name:'gpid',
            index:'gpid', 
             editoptions:{readonly: true},
            sortable: true,
            editable: true,            
            width:90
        },

        {
            name:'nombre',
            index:'nombre',
            sortable: true, 
             editrules: { required: true},
             editable: true,    
            width:100
        },

        {
            name:'division',
            index:'division', 
            sortable: true,
             editable: true,   
              editrules: { required: true},
            width:100, 
            align:"right"
        },
        
        {
            name:'subdivision',
            index:'subdivision',
            sortable:true, 
             editable: true, 
              editrules: { required: true},
            width:100, 
            align:"rigth"
        },
        

        {
            name:'vicepresidencia',
            index:'vicepresidencia',
            sortable: true, 
            width:120, 
             editrules: { required: true},
             editable: true,    
            align:"right"
        },


        {
            name:'correo',
            index:'correo',
            sortable: true, 
            width:80, 
             editrules: { required: true, email: true},
             editable: true,    
            align:"right"
        },


        {
            name:'telefono',
            index:'telefono',
            sortable: true, 
            width:80, 
             editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },


        {
            name:'extension',
            index:'extension',
            sortable: true, 
            width:80,
              editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },


        {
            name:'gpid_jefe',
            index:'gpid_jefe',
            sortable: true, 
             editrules: { required: true, number: true},
            width:80, 
             editable: true,    
            align:"right"
        },


        {
            name:'nombre_jefe',
            index:'nombre_jefe',
            sortable: true, 
            width:100,
             editable: true, 
              editrules: { required: true},
            align:"right"
        },


        {
            name:'correo_jefe',
            index:'correo_jefe',
            sortable: true, 
            width:120, 
             editable: true,   
            editrules: { required: true, email: true},
            align:"right"
        },
 
        {
            name:'actions',
            index:'actions',
            sortable: false, 
            width:80, 
                        align:"center"
        }  		
        ],
        rowNum:10,
        rowList:[10,20,30],
        pager: '#generalistas_pager',
        sortname: 'folio',
        viewrecords: true,
        sortable: true,
        sortorder: "desc",
        multiselect: true,
        caption:"Solicitudes Pendientes de Autorizacion",
        loadonce : false,
        rowTotal: 'total',
        records:'records',
        jsonReader: {
            repeatitems: false,
            id: "folio"
        }, 
        gridComplete: function(){
 	  
            var ids =$("#generalistas_grid").jqGrid('getDataIDs');
	  
            for(var i=0;i < ids.length;i++){
                var folio_ = ids[i]; 
               
                icon2= " <img src='img/accept.png'alt='Aceptar' title='Aceptar' height='16' onclick=\"changeStatusSolicitudAcceso('"+folio_+"',1);\" width='16'  />";
                icon3= " <img src='img/icon2.png' alt='Rechazar' title='Rechazar' height='18' onclick=\"changeStatusSolicitudAcceso('"+folio_+"',2);\" width='18'  />";
                $("#generalistas_grid").jqGrid('setRowData',ids[i],{
                    actions:icon2+icon3
                }); 
            }
 
        }
    });
    $("#generalistas_grid").jqGrid('navGrid','#generalistas_pager',{
        edit:true,
        add:true,
        view :true,
        del:true
    },{},{},{closeAfterEdit:true},{} );

}

var myDelOptions = {
            
    onclickSubmit: function(rp_ge, rowid) {
                      
       // alert("The row with rowid="+rowid+" will be deleted");
        
        $("#generalistas_aut_grid").delRowData(rowid);
                        

        //                jQuery("#grid_id").jqGrid('saveRow',rowid, false);

        return true;
    },
    url:'solicitud.do?action=del'
//,  processing:true
};

function initAutorizadosGrid(){
    
    $("#generalistas_aut_grid").jqGrid({
        url:'generalistas.do?type=1',
        editurl:'solicitud.do?action=edit',
        datatype: "json",
        width:1000,
     
        colNames:['Folio','Gpid','Nombre','Division','SubDivision','Vicepresidencia',
        'Correo','Telefono','Extension','Gpid Jefe','Nombre Jefe','Correo Jefe'],
        colModel:[
        {
            name:'folio',
            index:'folio',
            sortable: true, 
             editable: true,       
            editoptions:{readonly: true},        
            width:55
        },

        {
            name:'gpid',
            index:'gpid', 
             editoptions:{readonly: true},
            sortable: true,
            editable: true,            
            width:90
        },

        {
            name:'nombre',
            index:'nombre',
            sortable: true, 
             editrules: { required: true},
             editable: true,    
            width:100
        },

        {
            name:'division',
            index:'division', 
            sortable: true,
             editable: true,   
              editrules: { required: true},
            width:100, 
            align:"right"
        },
        
        {
            name:'subdivision',
            index:'subdivision',
            sortable:true, 
             editable: true, 
              editrules: { required: true},
            width:100, 
            align:"rigth"
        },
        

        {
            name:'vicepresidencia',
            index:'vicepresidencia',
            sortable: true, 
            width:100, 
             editrules: { required: true},
             editable: true,    
            align:"right"
        },


        {
            name:'correo',
            index:'correo',
            sortable: true, 
            width:80, 
             editrules: { required: true, email: true},
             editable: true,    
            align:"right"
        },


        {
            name:'telefono',
            index:'telefono',
            sortable: true, 
            width:80, 
             editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },


        {
            name:'extension',
            index:'extension',
            sortable: true, 
            width:80,
              editrules: { required: true, number: true},
             editable: true,    
            align:"right"
        },


        {
            name:'gpid_jefe',
            index:'gpid_jefe',
            sortable: true, 
             editrules: { required: true, number: true},
            width:80, 
             editable: true,    
            align:"right"
        },


        {
            name:'nombre_jefe',
            index:'nombre_jefe',
            sortable: true, 
            width:100,
             editable: true, 
              editrules: { required: true},
            align:"right"
        },


        {
            name:'correo_jefe',
            index:'correo_jefe',
            sortable: true, 
            width:100, 
             editable: true,   
            editrules: { required: true, email: true},
            align:"right"
        }
//        //,
//
//
//        {
//            name:'actions',
//            index:'actions',
//            sortable: false, 
//            width:80, 
//            
//            align:"center"
//        } 		
           		
        ],
        rowNum:10,
        rowList:[10,20,30],
        pager: '#generalistas_aut_pager',
        sortname: 'folio',
        viewrecords: true,
        sortable: true,
        multiselect: true,
        sortorder: "desc",
        caption:"Solicitudes de Acceso Autorizadas",
        loadonce : false,
        rowTotal: 'total',
        records:'records',
        jsonReader: {
            repeatitems: false,
            id: "folio"
   
        },
        gridComplete: function(){
 	  
            var ids =$("#generalistas_aut_grid").jqGrid('getDataIDs');
	  
//            for(var i=0;i < ids.length;i++){
//                var cl = ids[i]; 
//                icon1 = " <img src='img/icon1.png' alt='alta' height='16' width='16' onclick=\"test('"+cl+"');\" />";					 
//                $("#generalistas_aut_grid").jqGrid('setRowData',ids[i],{
//                    actions:icon1
//                }); 
//            }
 
        }
    });
    $("#generalistas_aut_grid").jqGrid('navGrid','#generalistas_aut_pager',{
        edit:true,
        add:false,
        del:true
    },{closeAfterEdit:true},{},myDelOptions,{});  
       
}